package db.parking.beans;

import java.io.Serializable;

/**
 * Parking lot entity
 * @author G15
 *
 */
public class ParkingLot implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int lotID;
	private int capacity;
	private int totalCars;
	private int [][][] locations;		//3d matrix for all postions
	private int prices[];
	private int x;
	private int y;
	private int z;
	private final int n = 5;//Constant Table Of Prices From DB
	private int florNum = 0;
	
	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int getZ() {
		return z;
	}

	public void setZ(int z) {
		this.z = z;
	}

	public int[][][] getLocations() {
		return locations;
	}
	
	public int getLocation(int x,int y,int z) {
		return locations[x][y][z];
	}

	public void setLocation(int x,int y,int z,int status) {
		this.locations[x][y][z] = status;
	}

	public int[] getPrices() {
		return prices;
	}

	public void setPrices(int price,int p) {
		this.prices[p] = price;
	}
	public ParkingLot(){
	}

	
	public ParkingLot(ParkingLot P){		//get details from data base
		this.lotID = P.getLotID();
		this.capacity = P.getCapacity();
		this.totalCars = P.getTotalCars();
		this.x = P.getX();
		this.y = P.getY();
		this.z = P.getZ();
		this.prices = new int[n];
		locations = new int [x][y][z];
	}
	
	public int getLotID() {
		return lotID;
	}
	public void setLotID(int lotID) {
		this.lotID = lotID;
	}
	public int getCapacity() {
		return capacity;
	}
	public void setCapacity(int capacity) {
		this.capacity = capacity;
	}
	public int getTotalCars() {
		return totalCars;
	}
	public void setTotalCars(int totalCars) {
		this.totalCars = totalCars;
	}
	
	public void printLocastions() {// print all the postions of parking lot
		System.out.println("locations for:"+lotID);
		for (int i = 0; i < z; i++) {
			for (int j = 0; j < y; j++) {
				for (int k = 0; k < x; k++)
					System.out.print(locations[k][j][i] + " ");
				System.out.println();
			}
			System.out.println();
		}
	}
	
	public void setFlor(int floorNo){
		this.florNum = floorNo;
	}
	
	public int[][] getFloor(){
		int floor[][]=new int[x][y];
		for(int i=0;i<y;i++)
			for(int j=0;j<x;j++)
				floor[j][i]=locations[j][i][this.florNum];
		return floor;
	}

	public int getFlorNum() {
		return florNum+1;
	}
	
}
